package com.jingtai.platform.controller.shop;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.jingtai.core.entity.BaseEntity;
import com.jingtai.core.entity.shop.GoodsSpecifications;
import com.jingtai.platform.service.shop.GoodsSpecificationsService;
import com.jingtai.platform.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.jingtai.validate.swagger.CApiParam;

/**
 * 商品规格表
 *
 * @author sunlaiqian
 * @date 2020-12-09 15:39:05
 */
@RestController
@RequestMapping("/platform/goodsspecifications")
@Api(tags = "商品规格表")
public class GoodsSpecificationsController{

    @Autowired
    private GoodsSpecificationsService goodsSpecificationsService;


    @ApiOperation("商品规格表列表查询")
    @GetMapping("/list")
    public ResultUtil aopGoodsSpecificationsList(@CApiParam(name = "page",value = "页数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("page") Integer page,
                              @CApiParam(name = "limit",value = "每页个数",required = true,cNotEmpty = true) @RequestParam("limit") Integer limit,
                              @CApiParam(name = "conditions",value = "查询条件",required = false) @RequestParam("conditions") String conditions){
        return goodsSpecificationsService.GoodsSpecificationslist(page, limit, conditions);
    }


    @ApiOperation("根据ID查询goodsSpecifications实体")
    @GetMapping("/getGoodsSpecificationsById")
    public ResultUtil GetGoodsSpecificationsById(@CApiParam(name = "id",value = "goodsSpecifications实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return goodsSpecificationsService.getGoodsSpecificationsById(id);
    }


    @ApiOperation("新增goodsSpecifications实体")
    @PostMapping("/add")
    @ApiOperationSupport(ignoreParameters = {"goodsSpecifications.id","goodsSpecifications.createTime","goodsSpecifications.updateTime","goodsSpecifications.deleteFlag"})
    public ResultUtil aopAddGoodsSpecifications(@RequestBody @Validated({BaseEntity.Create.class}) GoodsSpecifications goodsSpecifications){
        return goodsSpecificationsService.addGoodsSpecifications(goodsSpecifications);
    }

    @ApiOperation("编辑goodsSpecifications实体")
    @PostMapping("/edit")
    @ApiOperationSupport(ignoreParameters = {"goodsSpecifications.createTime","goodsSpecifications.updateTime","goodsSpecifications.deleteFlag"})
    public ResultUtil aopEditGoodsSpecifications(@RequestBody @Validated({BaseEntity.Update.class}) GoodsSpecifications goodsSpecifications){
        return goodsSpecificationsService.editGoodsSpecifications(goodsSpecifications);
    }

    @ApiOperation("根据ID删除goodsSpecifications实体")
    @GetMapping("/delGoodsSpecificationsById")
    public ResultUtil aopDelGoodsSpecificationsById(@CApiParam(name = "id",value = "goodsSpecifications实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return goodsSpecificationsService.delGoodsSpecificationsById(id);
    }

    @ApiOperation("查询所有的一级分类")
    @GetMapping("/selectGoodsSpecificationsOfOne")
    public ResultUtil aopSelectGoodsSpecificationsOfOne(){
        return goodsSpecificationsService.selectGoodsSpecificationsOfOne();
    }

    @ApiOperation("查询所有的一级分类和耳机分类")
    @GetMapping("/selectGoodsSpecificationsOfAll")
    public ResultUtil aopSelectGoodsSpecificationsOfAll(){
        return goodsSpecificationsService.selectGoodsSpecificationsOfAll();
    }

    @ApiOperation("根据商品编号查询规格")
    @GetMapping("/selectGoodsSpecificationsByGoodsCode")
    public ResultUtil selectGoodsSpecificationsByGoodsCode(@CApiParam(name = "goodsCode",value = "商品编号",required = true,cNotEmpty = true) @RequestParam("goodsCode") String goodsCode,
                                                           @CApiParam(name = "type",value = "0：供应商 1：商户",required = true,cNotEmpty = true) @RequestParam("type") Integer type){
        return goodsSpecificationsService.selectGoodsSpecificationsByGoodsCode(goodsCode,type);
    }
}






